import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [{
        path: '/login',
        component: () =>
            import ('@/views/login/index'),
        hidden: true
    },

    {
        path: '/404',
        component: () =>
            import ('@/views/404'),
        hidden: true
    },

    // {
    //     path: '/',
    //     component: Layout,
    //     redirect: '/dashboard',
    //     children: [{
    //         path: 'dashboard',
    //         name: '首页看板',
    //         component: () =>
    //             import ('@/views/dashboard/index'),
    //         meta: { title: '首页看板', icon: 'dashboard' }
    //     }]
    // },
  {
    path: '/',
    component: Layout,
    children: [{
      path: '',
      name: 'homeView',
      hidden: true,
      component: () =>
        import ('@/views/audit/'),
      meta: {
        cache: true,
        activeMenu: '/audit/list',
        title:'我的审批'
      }
    }]
  },
  {
    path: '/audit/list',
    component: Layout,
    children: [{
      path: '',
      name: 'auditList',
      hidden: true,
      component: () =>
        import ('@/views/audit/'),
      meta: {
        cache: true,
        title:'我的审批'
      }
    }]
  },
    {
        path: '/requirements',
        component: Layout,
        hidden: true,
        children: [{
                path: 'createRequirements',
                name: 'createRequirements',
                hidden: true,
                component: () =>
                    import ('@/views/requirements/createRequirement/index'),
                meta: { title: '创建新需求', icon: 'dashboard', activeTitle: '需求管理', activeMenu: '/requirements/requirements' }
            },
            {
                path: 'requirementDetail',
                name: 'requirementDetail',
                hidden: true,
                component: () =>
                    import ('@/views/requirements/requirementDetail/index'),
                meta: { title: '需求详情', icon: 'dashboard', activeTitle: '需求管理', activeMenu: '/requirements/requirements' }
            },
            {
                path: 'reqCreateEdit',
                name: 'reqCreateEdit',
                component: () => import('@/views/projectInformation/createEdit'),
                title: '创建自研立项',
                hidden: true,
                meta: { title: '创建自研立项', icon: 'dashboard', affix: true, activeTitle: '需求管理', activeMenu: '/requirements/requirements' }
            },
        ]
    },
    {
        path: '/projectInformation',
        component: Layout,
        hidden: true,
        children: [{
                path: 'createEdit',
                name: 'createEdit',
                component: () => import('@/views/projectInformation/createEdit'),
                title: '创建自研立项',
                hidden: true,
                meta: { title: '创建自研立项', icon: 'dashboard', affix: true, activeTitle: '自研立项', activeMenu: '/projectInformation/projectInfoManagement' }
            },
            // 自研立项详情
            {
                path: 'projectDetail',
                component: () => import('@/views/projectInformation/selfDetails'),
                name: 'projectDetail',
                title: '自研立项详情',
                hidden: true,
                meta: {
                    title: '自研立项详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeTitle: '自研立项',
                    activeMenu: '/projectInformation/projectInfoManagement'
                }
            },
            // 立项审批详情
            {
                path: 'auditDetail',
                component: () => import('@/views/projectInformation/auditDetails'),
                name: 'auditDetail',
                title: '立项审批详情',
                hidden: true,
                meta: {
                    title: '立项审批详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeTitle: '立项审批',
                    activeMenu: '/projectInformation/examine/list'
                }
            },
            // 我的审批---自研立项详情
            {
                path: 'selfAuditDetails',
                component: () => import('@/views/projectInformation/myAuditDetails/selfAuditDetails'),
                name: 'selfAuditDetails',
                title: '立项审批详情',
                hidden: true,
                meta: {
                    title: '立项审批详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeTitle: '我的审批',
                    activeMenu: '/audit/list'
                }
            },
            // 我的审批---立项审批详情
            {
                path: 'proAuditDetails',
                component: () => import('@/views/projectInformation/myAuditDetails/proAuditDetails'),
                name: 'proAuditDetails',
                title: '立项审批详情',
                hidden: true,
                meta: {
                    title: '立项审批详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeTitle: '我的审批',
                    activeMenu: '/audit/list'
                }
            },
            {
                path: 'submitApproval',
                component: () => import('@/views/projectInformation/submitApproval'),
                name: 'submitApproval',
                title: '创建立项审批',
                hidden: true,
                meta: {
                    title: '创建立项审批',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeTitle: '立项审批',
                    activeMenu: '/projectInformation/examine/list'
                }
            }
        ]
    },
    {
        path: '/projectManagement',
        component: Layout,
        hidden: true,
        children: [{
                path: 'edit',
                component: () => import('@/views/projectManagement/project/edit'),
                name: 'projectManagementEdit',
                hidden: true,
                meta: {
                    title: '项目编辑',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectManagement/project/list',
                    activeTitle: '项目列表'
                }
            },
            {
                path: 'details',
                component: () => import('@/views/projectManagement/project/details'),
                name: 'projectManagementDetails',
                hidden: true,
                meta: {
                    title: '项目详情',
                    icon: 'dashboard',
                    cache: true,
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectManagement/project/list',
                    activeTitle: '项目列表'
                }
            },
            {
                path: 'change',
                component: () => import('@/views/projectManagement/project/changeTask'),
                name: 'projectManagementTaskChange',
                hidden: true,
                meta: {
                    title: '任务批量变更',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectManagement/project/list',
                    activeTitle: '项目列表'
                }
            },
            {
                path: '/detail',
                component: () => import('@/views/projectManagement/taskList/details'),
                name: 'projectManagementTaskDetail',
                hidden: true,
                meta: {
                    title: '任务详情',
                    icon: 'dashboard',
                    noCache: true,
                    cache: true,
                    affix: true,
                    activeMenu: '/projectManagement/taskList/list',
                    activeTitle: '任务管理'
                }
            },
            {
                path: '/detail',
                component: () => import('@/views/projectManagement/planList/details'),
                name: 'projectManagementPlanDetail',
                hidden: true,
                meta: {
                    title: '计划详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true
                }
            },
            {
                path: '/report/create',
                component: () => import('@/views/projectManagement/report/create'),
                name: 'projectManagementReportCreate',
                hidden: true,
                meta: {
                    title: '写报告',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectManagement/report/list',
                    activeTitle: '项目报告'
                }
            },
            {
                path: '/report/detail',
                component: () => import('@/views/projectManagement/report/detail'),
                name: 'projectManagementReportDetail',
                hidden: true,
                meta: {
                    title: '报告详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectManagement/report/list',
                    activeTitle: '项目报告'
                }
            },
            {
                path: '/problem/detail',
                component: () => import('@/views/projectManagement/problem/detail'),
                name: 'problem-detail',
                hidden: true,
                meta: {
                    title: '问题详情',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectManagement/problem/list',
                    activeTitle: '项目问题'
                }
            },
            {
                path: 'problem/list',
                component: () => import('@/views/projectManagement/problem/list'),
                name: 'problem-list',
                hidden: true,
                meta: {
                    title: '项目问题',
                    noCache: true,
                    affix: true,
                }
            },
            {
                path: 'meeting/list',
                component: () => import('@/views/projectManagement/meeting/list'),
                name: 'meeting-list',
                hidden: true,
                meta: {
                    title: '项目会议',
                    noCache: true,
                    affix: true,
                }
            },
          {
            path: 'file/detail',
            component: () => import('@/views/projectManagement/file/detail'),
            name: 'project-file-detail',
            hidden: true,
            meta: {
              title: '项目文件详情',
              noCache: true,
              affix: true,
            }
          },
        ]
    },

    {
        path: '/projectSetting',
        component: Layout,
        name: 'setting',
        children: [{
                path: 'modeSetting',
                component: () => import('@/views/projectSetting/model/list'),
                name: 'modeSettingList',
                hidden: true,
                meta: {
                    title: '项目模板',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectSetting/modeSetting',
                }
            },
            {
                path: 'modeSetting/edit',
                component: () => import('@/views/projectSetting/model/edit'),
                name: 'modeSettingEdit',
                hidden: true,
                meta: {
                    title: '模板编辑',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectSetting/modeSetting',
                    activeTitle: '模板设置'
                }
            },
            {
                path: 'modeSetting/details',
                component: () => import('@/views/projectSetting/model/details'),
                name: 'modeSettingDetails',
                hidden: true,
                meta: {
                    title: '模板详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/projectSetting/modeSetting',
                    activeTitle: '模板设置'
                }
            }
        ]
    },
    {
        path: '/qualityStandard',
        component: Layout,
        children: [{
                path: 'createQuality',
                name: 'createQuality',
                hidden: true,
                component: () =>
                    import ('@/views/qualityStandard/create/index'),
                meta: { title: '创建检验依据', icon: 'dashboard', activeTitle: '检验依据', activeMenu: '/qualityStandard/qualityStandardList' }
            },
            {
                path: 'qualityDetail',
                name: 'qualityDetail',
                hidden: true,
                component: () =>
                    import ('@/views/qualityStandard/detail/index'),
                meta: { title: '检验依据详情', icon: 'dashboard', activeTitle: '检验依据', activeMenu: '/qualityStandard/qualityStandardList' }
            },
            {
                path: 'myAuditDetail',
                name: 'myAuditDetail',
                hidden: true,
                component: () =>
                    import ('@/views/qualityStandard/myAuditDetail/index'),
                meta: { title: '检验依据审批详情', icon: 'dashboard', activeTitle: '我的审批', activeMenu: '/audit/list' }
            }
        ]
    },
    {
        path: '/sampleInspection',
        component: Layout,
        redirect: 'index',
        children: [{
                path: 'applied/createTest',
                name: 'createTest',
                hidden: true,
                component: () => import('@/views/sampleInspection/applied/createTest'),
                meta: { activeTitle: '送检申请', activeMenu: '/sampleInspection/applied', title: '送检申请创建' }
            },
            {
                path: 'details',
                name: 'sampleInspectionDetails',
                component: () => import('@/views/sampleInspection/details'),
                meta: { title: '送检申请详情', activeTitle: '送检申请', icon: 'dashboard', noCache: true, affix: true, activeMenu: '/sampleInspection/applied' },
                hidden: true
            },
            {
                path: 'myDetails',
                name: 'sampleInspectionMyDetails',
                component: () => import('@/views/sampleInspection/myDetails'),
                meta: { title: '送检审批', activeTitle: '我的审批', icon: 'dashboard', noCache: true, affix: true, activeMenu: '/audit/list' },
                hidden: true
            },
            {
                path: 'taskDetails',
                name: 'sampleInspectionTaskDetails',
                component: () => import('@/views/sampleInspection/task'),
                meta: {
                    activeTitle: '检验任务',
                    title: '检验任务详情',
                    icon: 'dashboard',
                    noCache: true,
                    affix: true,
                    activeMenu: '/sampleInspection/dealWith'
                },
                hidden: true
            },
            {
                path: 'myTask',
                name: 'sampleInspectionMyTask',
                component: () => import('@/views/sampleInspection/myTask'),
                meta: { title: '结果审批', activeTitle: '我的审批', icon: 'dashboard', noCache: true, affix: true, activeMenu: '/audit/list' },
                hidden: true
            },
          {
            path: 'inspectionResults/file',
            name: 'inspectionResults-file',
            component: () => import('@/views/projectManagement/file/detail'),
            meta: { title: '检验结果', activeTitle: '检验结果', icon: 'dashboard', noCache: true, affix: true, activeMenu: '/sampleInspection/inspectionResults' },
            hidden: true
          }

        ]
    },
    {
        path: '/samples',
        component: Layout,
        name: 'samples',
        children: [{
            path: 'details',
            name: 'samplesDetailss',
            hidden: true,
            component: () => import('@/views/samples/details')
        }]

    },
    {
        path: '/sampleManagement',
        component: Layout,
        name: 'sampleManagement',
        children: [{
                path: 'retention/details',
                name: 'sampleManagementDetails',
                hidden: true,
                component: () => import('@/views/sampleManagement/retention/details'),
                meta: { activeMenu: '/sampleManagement/retention', title: '留样记录详情', activeTitle: '留样记录', }
            },
            {
                path: 'destruction/create',
                name: 'destructionCreate',
                hidden: true,
                component: () => import('@/views/sampleManagement/destruction/create'),
                meta: { activeMenu: '/sampleManagement/destruction', activeTitle: '样品销毁', title: '创建销毁申请' }
            },
            {
                path: 'destruction/apply',
                name: 'destructionApply',
                hidden: true,
                component: () => import('@/views/sampleManagement/destruction/details/apply.vue'),
                meta: { activeMenu: '/sampleManagement/destruction', activeTitle: '样品销毁', title: '销毁申请详情' }
            },
            {
                path: 'destruction/particular',
                name: 'destructionParticular',
                hidden: true,
                component: () => import('@/views/sampleManagement/destruction/details/particular.vue'),
                meta: { activeMenu: '/sampleManagement/destruction', activeTitle: '样品销毁', title: '销毁明细详情' }
            },
            {
                path: 'destruction/approval',
                name: 'destructionApproval',
                hidden: true,
                component: () => import('@/views/sampleManagement/destruction/details/approval.vue'),
                meta: { activeMenu: '/audit/list', activeTitle: '我的审批', title: '样品销毁审批' }
            }
        ]
    },
    {
        path: '/stability',
        component: Layout,
        name: 'stability',
        children: [{
                path: 'giveUp/create',
                name: 'giveUpCreate',
                hidden: true,
                component: () => import('@/views/stability/giveUp/create'),
                meta: { activeMenu: '/stability/giveUp', activeTitle: '稳定性方案', title: '创建稳定性方案' }
            },
            {
                path: 'giveUp/created',
                name: 'giveUpCreated',
                hidden: true,
                component: () => import('@/views/stability/giveUp/created'),
                meta: { activeMenu: '/stability/giveUp', activeTitle: '稳定性方案', title: '创建稳定性方案' }
            },
            {
                path: 'giveUp/tableDetail',
                name: 'giveUpTableDetail',
                hidden: true,
                component: () => import('@/views/stability/giveUp/tableDetail'),
                meta: { activeMenu: '/stability/giveUp', activeTitle: '稳定性方案', title: '创建稳定性方案' }
            },
            {
                path: 'giveUp/planDetail',
                name: 'giveUpPlanDetail',
                hidden: true,
                component: () => import('@/views/stability/giveUp/planDetail'),
                meta: { activeMenu: '/stability/giveUp', activeTitle: '稳定性方案', title: '创建稳定性方案' }
            },
            {
                path: 'giveUp/details',
                name: 'giveUpDetails',
                hidden: true,
                component: () => import('@/views/stability/giveUp/details'),
                meta: { activeMenu: '/stability/giveUp', activeTitle: '稳定性方案', title: '稳定性方案详情' }
            },
            {
                path: 'giveUp/myDetails',
                name: 'giveUpmyDetail',
                hidden: true,
                component: () => import('@/views/stability/giveUp/myDetail'),
                meta: { activeMenu: '/audit/list', title: '稳定性方案审批', activeTitle: '我的审批', }
            },
            {
                path: 'management/details',
                name: 'managementDetails',
                hidden: true,
                component: () => import('@/views/stability/management/details'),
                meta: { title: '放/取样计划详情', icon: 'dashboard', activeMenu: '/stability/management', activeTitle:   '放/取样计划' }
            },
            {
                path: 'change/details',
                name: 'changeDetails',
                hidden: true,
                component: () => import('@/views/stability/change/details'),
                meta: { title: '稳定性箱变更详情', icon: 'dashboard', activeMenu: '/stability/change', activeTitle:   '稳定性箱变更' }
            },
            {
                path: 'change/detailss',
                name: 'changeDetailss',
                hidden: true,
                component: () => import('@/views/stability/change/approveDetail'),
                meta: { title: '稳定性箱变更审批', icon: 'dashboard', activeMenu: '/audit/list', activeTitle:   '我的审批' }
            }

        ]
    },
    {
        path: '/projectManagement/audit/detail',
        component: Layout,
        children: [{
            path: '',
            name: 'projectAuditDetail',
            hidden: true,
            component: () => import('@/views/projectManagement/audit/detail'),
            meta: {
                activeMenu: '/audit/list',
                activeTitle: '我的审批'
            }
        }]
    },


    {
        path: '/user',
        component: Layout,
        redirect: 'user',
        children: [{
            path: 'profile',
            name: 'profile',
            component: () => import('@/views/user/profile')
        }]
    }
]

const createRouter = () =>
    new Router({
        mode: 'history', // history： require service support
        scrollBehavior: () => ({ y: 0 }),
        routes: constantRoutes
    })

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
